var pool = require('../../config/mysql.connection');
var mapping = require('./mapping/assist.mapping');
var model = require('./user.server.model');

module.exports = {
	queryAssistAll:function(param , callback){
		pool.getConnection(function(err,connection){
			connection.query(mapping.queryAssistAll(param.name),function(err,result){
				if(err){
					throw err;
				}
				callback(result);
				connection.release();
			});
		});
	},
	removeAssist:function(param , callback){
		pool.getConnection(function(err,connection){
			connection.query(mapping.removeAssist(param.id,param.name),function(err,result){
				if(err){
					throw err;
				}
				model.setRedisNameData(param.name);
				callback(result);
				connection.release();
			});
		});
	},
	updateAssist:function(param,callback){
		pool.getConnection(function(err,connection){
			connection.query(mapping.updateAssist(param),function(err,result){
				if(err){
					throw err;
				}
				model.setRedisNameData(param.name);
				callback(result);
				connection.release();
			});
		});
	},
	addAssist:function(param,callback){
		pool.getConnection(function(err,connection){
			connection.query(mapping.addAssist(param),function(err,result){
				if(err){
					throw err;
				}
				model.setRedisNameData(param.name);
				callback(result);
				connection.release();
			});
		});
	}
};